<?php

namespace App\Http\Resources;

use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class PollingPlanLogResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'polling_id' => $this->polling_id,
            'polling_plan_id' => $this->polling_plan_id,
            'polling_number' => $this->polling->number ?? '',
            'customer_name' => $this->polling->customer_name ?? '',
            'customer_user_name' => $this->polling->customer_user_name ?? '',
            'customer_user_telephone' => $this->polling->customer_user_telephone ?? '',
            'customer_address' => $this->polling->customer_address ?? '',
            'user_name' => $this->polling->user_name ?? '',
            'create_user_name' => $this->polling_plan->create_user_name ?? '',
            'plan_at' => $this->polling->plan_at ?? '',
            'status' => $this->status ?? '',
            'status_text' => '成功',
            'create_time' => Carbon::parse($this->create_time)->toDateTimeString(),
        ];
    }
}
